#include "comm.hpp"
#include <iostream>
bool check(const char* s)
{
  std::string str;
  while(*s != '\n')
  {
    str += *s;
    s++;
  }
  return str != "quit";
}

int main()
{
  // 打开命名管道
  int fd = open(fileName.c_str(), O_WRONLY);
  if (fd < 0)
  {
    std::cout << errno << " : " << strerror(errno) << std::endl;
    exit(-1);
  }
  // 写入内容
  char buffer[NUM];
  std::cout << "Input : ";
  char* ret = fgets(buffer, NUM, stdin);
  while (check(ret))
  {
    buffer[strlen(buffer) - 1] = '\0';
    write(fd, buffer, strlen(buffer));
    std::cout << "Input : ";
    ret = fgets(buffer, NUM, stdin);
  }
  close(fd);
  return 0;
}
